package com.cssy.xxkj.logic.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicProductionPlanItemDAO;
import com.cssy.xxkj.logic.entity.LogicProductionPlanItemDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-26
 */
public class LogicProductionPlanItemDAOImpl extends SqlMapClientDaoSupport implements LogicProductionPlanItemDAO {

    /**
     * 插入数据
     * @param logicProductionPlanItemDO
     * @return 插入数据的主键
     */
    public String insertLogicProductionPlanItemDO(LogicProductionPlanItemDO logicProductionPlanItemDO) {
        Object id = getSqlMapClientTemplate().insert("LogicProductionPlanItem.insert", logicProductionPlanItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicProductionPlanItemDO
     * @return 查出的记录数
     */
    public Integer countLogicProductionPlanItemDOByExample(LogicProductionPlanItemDO logicProductionPlanItemDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionPlanItem.countByDOExample", logicProductionPlanItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicProductionPlanItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicProductionPlanItemDO(LogicProductionPlanItemDO logicProductionPlanItemDO) {
        int result = getSqlMapClientTemplate().update("LogicProductionPlanItem.update", logicProductionPlanItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicProductionPlanItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicProductionPlanItemDO> findListByExample(LogicProductionPlanItemDO logicProductionPlanItemDO) {
        List<LogicProductionPlanItemDO> list = getSqlMapClientTemplate().queryForList("LogicProductionPlanItem.findListByDO", logicProductionPlanItemDO);
        return list;
    }
    
    public List<LogicProductionPlanItemDO> findListByMap(Map<String, Object> paramMap){
    	 List<LogicProductionPlanItemDO> list = getSqlMapClientTemplate().queryForList("LogicProductionPlanItem_ex.findListByMap", paramMap);
         return list;
    }

    /**
     * 根据主键获取logicProductionPlanItemDO
     * @param id
     * @return logicProductionPlanItemDO
     */
    public LogicProductionPlanItemDO findLogicProductionPlanItemDOByPrimaryKey(String id) {
        LogicProductionPlanItemDO logicProductionPlanItemDO = (LogicProductionPlanItemDO) getSqlMapClientTemplate().queryForObject("LogicProductionPlanItem.findByPrimaryKey", id);
        return logicProductionPlanItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicProductionPlanItemDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProductionPlanItem.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicProductionPlanItemDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicProductionPlanItemDO> list = getSqlMapClientTemplate().queryForList("LogicProductionPlanItem_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionPlanItem_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Integer deletePlanId(String id) {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProductionPlanItem_ex.deletePlanId", id);
        return rows;
	}

}